<script>
	import './index.css'
	import {
		pageIndexSetting
	} from './setting.js'
	export default {
		// #ifdef H5
		onLaunch: function() {
			this.pageAnimation = false;
			this.show()
			this.$router.beforeEach((to, from, next) => {
				this.hide(next)
			})
			this.$router.afterEach(() => {
				setTimeout(this.show, 50)
			})
		},
		methods: {
			hide(callback) {
				let $this = this;
				$this.pageAnimation = false;
				const classList = document.querySelector('uni-page').classList
				let pagePath = window.location.hash;
				var str = pagePath.split("?"); //根据？截取url
				var strs = (str[0].split("&")).toString();
				pageIndexSetting.forEach(page => {
					if ('#/' + page.path == strs) {
						$this.pageAnimation = true;
					}
				})
				if ( $this.pageAnimation != true) {
					classList.remove('animation-show')
					callback && callback()
					return false
				}
				classList.add('animation-before', 'animation-leave')
				classList.remove('animation-show')
				setTimeout(() => {
					classList.remove('animation-before', 'animation-leave')
					callback && callback()
				}, 300)
			},
			show() {
				let $this = this;
				$this.pageAnimation = false;
				const classList = document.querySelector('uni-page').classList
				let pagePath = window.location.hash;
				var str = pagePath.split("?"); //根据？截取url
				var strs = (str[0].split("&")).toString();
				pageIndexSetting.forEach(page => {
					if ('#/' + page.path == strs) {
						$this.pageAnimation = true;
					}
				})
				if ( $this.pageAnimation != true) {
					classList.add('animation-show')
					return false
				}
				setTimeout(() => {
					classList.add('animation-enter', 'animation-after', 'animation-show')
					setTimeout(() => {
						classList.remove('animation-before', 'animation-after', 'animation-enter')
					}, 300)
				}, 20)
			}
		},
		// #endif
	}
</script>
